<?php
require_once('../database/db_mysql.php');

$dbhost = "localhost";
$dbuser = "root";
$dbpw = "";
$dbname = "helpdb";
$pconnect = 0;

$fieldArr = array(
    "name",
    //"lastlogin",
    "exp",
    "goodcomment",
    "badcomment",
);

echo '<table cellpadding="0" cellspacing="0" border="0" id="searchtab" class="display"><thead><tr class="gradeC">';
foreach ($fieldArr as $field) {
    echo "<th>$field</th>";
}
echo "</tr></thead><tbody>";

$db = new DB($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$whereStr = join(" and ", explode("#", $_POST["wherearg"]));
if (strlen($whereStr) > 0) {
    $whereStr = "where $whereStr";
}
$fieldStr = join(",", $fieldArr);
$sqlStat = "select $fieldStr from user $whereStr";
$query = $db->query($sqlStat);
while ($row = $db->fetch_array($query)) {
    echo '<tr class="gradeA">';
    foreach ($fieldArr as $field) {
        echo '<td>'.$row[$field]."</td>";
    }
    echo "</tr>";
}
echo "<tbody></table>";

?>
